package com.zz.ecommerce.searchManage.declarationStatus;

import com.zz.ecommerce.common.CommonDao;
import com.zz.ecommerce.common.GridRequest;
import com.zz.ecommerce.common.GridResult;
import com.zz.ecommerce.searchManage.declarationStatus.bean.TReceiptsQdc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 回执查询服务
 */
@Controller
@RequestMapping("/searchManage/declarationStatus")
public class TReceiptsQdcController {
    @Autowired
    CommonDao commonDao;

    /**
     * 报文回执查询页
     *
     * @return
     */
    @RequestMapping(value = "init", method = RequestMethod.GET)
    public String TReceiptsQdcManager() {
        return "searchManage/declarationStatus/treceiptsqdc_manager";
    }

    /**
     * 查询列表
     *
     * @param gridRequest
     * @param tReceiptsQdc
     * @return
     */
    @RequestMapping(value = "qryTReceiptsQdcPage", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public GridResult<TReceiptsQdc> qryTReceiptsQdcPage(GridRequest gridRequest, TReceiptsQdc tReceiptsQdc) {
        List<TReceiptsQdc> list = commonDao.pageWhere("T_RECEIPTS_QDC", tReceiptsQdc, gridRequest.getStart(), gridRequest.getEnd(), " file_date_time desc ", "");
        long count = commonDao.countWhere("T_RECEIPTS_QDC", tReceiptsQdc, "");
        return new GridResult<TReceiptsQdc>(list, gridRequest, count);
    }

    @RequestMapping(value = "saveTReceiptsQdc", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public String saveTReceiptsQdc(HttpSession session, TReceiptsQdc tReceiptsQdc) {
        return "success";
    }

    @RequestMapping(value = "getTReceiptsQdcDetail", method = {RequestMethod.GET, RequestMethod.POST})
    public String getTReceiptsQdcDetail(TReceiptsQdc tReceiptsQdc, ModelMap modelMap, String modify) {
        TReceiptsQdc tReceiptsQdcDetail = (TReceiptsQdc) commonDao.qryOneCommon("T_RECEIPTS_QDC", tReceiptsQdc, "");
        modelMap.put("tReceiptsQdc", tReceiptsQdcDetail);
        modelMap.put("modify", "false".equals(modify));
        return "searchManage/declarationStatus/treceiptsqdc_detail";
    }
}
